var baseUrl = '';
// var baseUrl = ''; baseUrl用途：前后端分离 前端放在不同服务器上可以直接指定请求地址
var curWwwPath = window.document.location.href;
// 如果本地环境测试的话baseUrl赋值为本地地址
if (curWwwPath.indexOf('localhost') > 0 || curWwwPath.indexOf('127.0.0.1') > 0) {
    baseUrl = 'http://localhost:80';
}
//服务层
app.service('tiebaService', function ($http) {
    //读取列表数据绑定到表单中
    this.findAll = function () {
        return $http.get('../tieba/findAll.do');
    }
    //分页
    this.findPage = function (page, rows) {
        return $http.get('../tieba/findPage.do?page=' + page + '&rows=' + rows);
    }
    //查询签到错误贴吧
    this.findOne = function (id) {
        return $http.get(baseUrl + '/tieba/findOne?id=' + id);
    }
    //查询实体
    this.updateOne = function (id) {
        return $http.get(baseUrl + '/tieba/getUpdate?id=' + id);
    }
    //增加
    this.add = function (entity) {
        return $http.post(baseUrl + '/tieba/add', entity);
    }
    //修改
    this.update = function (entity) {
        return $http.post(baseUrl + '/tieba/update', entity);
    }
    //删除
    this.dele = function (ids) {
        return $http.get('../tieba/delete.do?ids=' + ids);
    }
    //搜索
    this.search = function (page, rows, searchEntity) {
        return $http.get(baseUrl + '/tieba/search?qq=' + searchEntity.qq);
    }

    //搜索Email
    this.searchEmail = function (searchEntity) {
        return $http.get(baseUrl + '/users/searchEmail?qq=' + searchEntity.qq);
    }

    //增加
    this.addEmail = function (entity) {
        return $http.post(baseUrl + '/users/addEmail', entity);
    }
});
